﻿using System.Data;
using System.Threading.Tasks;
using JX.Core;
using JX.Core.Entity;

namespace JX.Application
{
	/// <summary>
	/// 数据库表：Contacter 的应用层服务接口.
	/// </summary>
	public partial interface IContacterServiceAppDapper : IServiceAppDapper<ContacterEntity>
	{
		#region 删除
		/// <summary>
		/// 通过主键批量删除，同时删除U_UserText、ClientLog和RemindItem的数据。
		/// </summary>
		/// <param name="contacterID">多个ID用“,”分隔</param>
		/// <returns></returns>
		bool DeleteByID(string contacterID);
		/// <summary>
		/// 通过主键批量删除，同时删除U_UserText、ClientLog和RemindItem的数据。
		/// </summary>
		/// <param name="contacterID">多个ID用“,”分隔</param>
		/// <returns></returns>
		Task<bool> DeleteByIDAsync(string contacterID);
		/// <summary>
		/// 根据UserName删除Contacter表数据，同时删除U_UserText、ClientLog和RemindItem的数据。
		/// </summary>
		/// <param name="userName"></param>
		/// <returns></returns>
		bool DeleteByUserName(string userName);
		/// <summary>
		/// 根据UserName删除Contacter表数据，同时删除U_UserText、ClientLog和RemindItem的数据。
		/// </summary>
		/// <param name="userName"></param>
		/// <returns></returns>
		Task<bool> DeleteByUserNameAsync(string userName);
		#endregion

		#region 是否存在扩展数据
		/// <summary>
		/// 是否存在扩展数据
		/// </summary>
		/// <param name="id"></param>
		/// <param name="tableName"></param>
		/// <returns></returns>
		bool IsExistDataOption(int id, string tableName = "U_UserText");
		/// <summary>
		/// 是否存在扩展数据
		/// </summary>
		/// <param name="id"></param>
		/// <param name="tableName"></param>
		/// <returns></returns>
		Task<bool> IsExistDataOptionAsync(int id, string tableName = "U_UserText");
		#endregion

		#region 添加扩展数据
		/// <summary>
		/// 添加联系人扩展表数据:从contacterEntity.Fields中获取表列及列值信息
		/// </summary>
		/// <param name="tableName"></param>
		/// <param name="contacterEntity"></param>
		/// <returns></returns>
		bool AddDataOption(string tableName, ContacterEntity contacterEntity);
		/// <summary>
		/// 添加联系人扩展表数据:从contacterEntity.Fields中获取表列及列值信息
		/// </summary>
		/// <param name="tableName"></param>
		/// <param name="contacterEntity"></param>
		/// <returns></returns>
		Task<bool> AddDataOptionAsync(string tableName, ContacterEntity contacterEntity);
		#endregion

		#region 修改扩展数据
		/// <summary>
		/// 修改联系人扩展表数据，不存在则添加:从contacterEntity.Fields中获取表列及列值信息
		/// </summary>
		/// <param name="tableName"></param>
		/// <param name="contacterEntity"></param>
		/// <returns></returns>
		bool UpdateDataOption(string tableName, ContacterEntity contacterEntity);
		/// <summary>
		/// 修改联系人扩展表数据，不存在则添加:从contacterEntity.Fields中获取表列及列值信息
		/// </summary>
		/// <param name="tableName"></param>
		/// <param name="contacterEntity"></param>
		/// <returns></returns>
		Task<bool> UpdateDataOptionAsync(string tableName, ContacterEntity contacterEntity);
		#endregion

		#region 删除扩展数据
		/// <summary>
		/// 删除扩展数据
		/// </summary>
		/// <param name="tableName"></param>
		/// <param name="id"></param>
		/// <returns></returns>
		bool DeleteDataOption(string tableName, int id);
		/// <summary>
		/// 删除扩展数据
		/// </summary>
		/// <param name="tableName"></param>
		/// <param name="id"></param>
		/// <returns></returns>
		Task<bool> DeleteDataOptionAsync(string tableName, int id);
		#endregion

		#region 得到扩展数据
		/// <summary>
		/// 根据主键得到扩展数据
		/// </summary>
		/// <param name="contacterID"></param>
		/// <param name="writeAndRead"></param>
		/// <returns></returns>
		DataTable GetDataOption(int contacterID, WriteAndReadEnum writeAndRead = WriteAndReadEnum.None);
		/// <summary>
		/// 根据主键得到扩展数据
		/// </summary>
		/// <param name="contacterID"></param>
		/// <param name="writeAndRead"></param>
		/// <returns></returns>
		Task<DataTable> GetDataOptionAsync(int contacterID, WriteAndReadEnum writeAndRead = WriteAndReadEnum.None);
		#endregion
	}
}